#include <Arduino.h>
#include "led.h"
#include "wifiControl.h"
#include "httpUtils.h"
#include "mqttControl.h"
#include "TFTControl.h"
#include "cJSON.h"
#include "user_Main.h"
#include "show_toast.h"
#include "getScroll.h"
void setup() {
   
  //初始化串口
    Serial.begin(115200);
    delay(3000);
    Serial.println("hello");
  //初始化wifi
    wifiControl_init();
    mqttControl_init();
   // randomSeed(micros());//设置一个随机数种子，用于生成随机数

    

    screen_init();
    

   // show_toast("sssss");
    createGetScroll();
    //createUserMain();
}
//只要串口有数据 就会执行这个函数
void serialEvent(){

    if(Serial.available()){

      // String url ="https://api.seniverse.com/v3/weather/now.json?key=Sjb7VFBPJbPzl6IJN&location="+Serial.readString()+"&language=zh-Hans&unit=c";
      // String data=http_getData(url);

      // getWeatherCityName(data);
      mqtt_Push("cocoaxf",Serial.readString().c_str());
    }


}
void loop() {
      //如果没有链接上mqtt 就去链接,心跳
    mqtt_loop();
          
    screen_loop();
    delay( 5 );
  
}